import Empty from '@/components/common/Empty.vue'
import { createApp } from 'vue'

let empty=null
const createEmpty=(el:HTMLElement) =>{
  empty=createApp(Empty)
  const fragment:any=document.createDocumentFragment()
  empty.mount(fragment)
  el.appendChild(fragment)
}
const destoryEmpty=(el:HTMLElement) =>{
  if(!empty) return
  el.removeAttribute('style')
  empty.unmount()
}
export default {
  mounted(el:HTMLElement, binding) {
    createEmpty(el)
  },
  updated(el:HTMLElement, binding){
    if(binding.value==binding.oldValue) return
    console.log(binding.value)
    if(binding.value){
      destoryEmpty(el)
    }else{
      createEmpty(el)
    }
  }
}